/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pedagio.modelo;

import com.pedagio.dominio.Consulta;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author pedroo
 */
public class ConsultaModelo extends AbstractTableModel {

    String[] column = {"Codigo", "Paciente", "Nome Medico", "Tipo", "Forma_Pagamento", "Hora", "Data_Consulta"};
    List<Consulta> data = new ArrayList<Consulta>();

    @Override
    public int getColumnCount() {
        return column.length;
    }

    @Override
    public int getRowCount() {
        return data.size();
    }

    public String getColumnName(int columnIndex) {
        return column[columnIndex];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {

        Consulta consulta = data.get(rowIndex);

        if (columnIndex == 0) {
            return consulta.getId().toString();
        } else if (columnIndex == 1) {
            return consulta.getPaciente();
        } else if (columnIndex == 2) {
            return consulta.getNome();
        } else if (columnIndex == 3) {
            return consulta.getTipo();
        } else if (columnIndex == 4) {
            return consulta.getFormaPagamento();
        } else if (columnIndex == 5) {
            return consulta.getHora();
        } else if (columnIndex == 6) {
            return consulta.getDataConsulta();
        } else {
            return null;
        }

    }

    public void addRow(Consulta consulta) {
        data.add(consulta);
    }

    public Consulta getRow(int rowIndex) {
        return data.get(rowIndex);
    }
}
